<?php
$form = $this->beginWidget('CActiveForm', array(
    'id'                     => 'ntt-form',
    'enableAjaxValidation'   => false,
    'enableClientValidation' => false,
    'focus'                  => array($model, 'name'),
    'errorMessageCssClass' => 'error',
    'htmlOptions'          => array(
        'enctype' => 'multipart/form-data',
        'class'   => 'form',
    ),
));
?>

<fieldset>
    <ul>
        <li>
            <?php
                $attrName = 'name';
                echo $form->labelEx($model, $attrName, array(
                    'class' => 'desc'
                ));
            ?>
            <div><?php
                echo $form->textField($model, $attrName, array(
                    'class' => 'text large'
                ));
                
                $attribute = 'activated_flag';
                echo $form->checkbox($model, $attribute, array(
                    'style' => 'display:inline-block;',
                ));
                echo CHtml::label($model->getAttributeLabel($attribute), 'DCfAlbum_activated_flag', array(
                    'style' => 'display:inline-block; font-weight:900;',
                    'class' => 'desc',
                ));
                
                echo $form->error($model, 'name');
            ?></div>
        </li>
        
        <li>
            <?php
                $attrName = 'artist';
                echo $form->labelEx($model, $attrName, array(
                    'class' => 'desc'
                ));
            ?>
            <div><?php
                echo $form->textField($model, $attrName, array(
                    'class' => 'text large'
                ));
                echo $form->error($model, $attrName);
            ?></div>
        </li>
        
        <li>
            <?php
            $attribute = 'category';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>

            <div>
                <?php
                echo '<label class="desc inline">Nhạc sĩ</label>';
                $options = DCfComposer::model()->getList();
                $attribute = 'composer_id';
                echo $form->dropDownList($model, $attribute, $options, array(
                    'style' => 'width: 150px',
                ));
                
                echo '<label class="desc inline" style="margin-left: 10px;">Album</label>';
                $options = DCfAlbum::model()->getList();
                $attribute = 'album_id';
                echo $form->dropDownList($model, $attribute, $options, array(
                    'style' => 'width: 200px',
                ));
                ?>
            </div>
        </li>
        
        <li>
            <?php
            $attribute = 'lyric';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>

            <div>
                <?php
                $this->widget('ext.ckeditor.CKEditorWidget', array(
                    'model'     => $model,
                    'attribute' => $attribute,
                    'config'    => array(
                        'height'   => 100,
                    ),
                ));
                
                echo $form->error($model, $attribute);
                ?>
            </div>
        </li>
        
        <li>
            <?php
            $attribute = 'musicFile';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>

            <div>
                <?php
                echo $form->fileField($model, $attribute);
                if ( ! $model->getIsNewRecord() ) {
                    $link = $model->params['upload_url'] . $model->getAttribute('file');
                    echo CHtml::link('Download', $link, array(
                        'style' => 'margin-left: 10px;'
                    ));
                }
                echo $form->error($model, $attribute);
                echo $form->hiddenField($model, 'file');
                ?>
            </div>
        </li>
        
        <li>
            <?php
                $attrName = 'counter';
                echo $form->labelEx($model, $attrName, array(
                    'class' => 'desc'
                ));
            ?>
            <div><?php
                echo $form->textField($model, $attrName, array(
                    'class' => 'text medium'
                ));
                echo $form->error($model, $attrName);
            ?></div>
        </li>
        
        <!-- buttons -->
        <li style="text-align: center;"><?php
            echo CHtml::submitButton($model->isNewRecord ? 'CREATE' : 'SAVE', array(
                'name'  => 'submit',
                'class' => 'ui-state-default ui-corner-all ui-button'
            ));
            echo CHtml::button('RESET', array(
                'id'    => 'btn-reset',
                'class' => 'ui-state-default ui-corner-all ui-button',
                'style' => 'margin:0 10px;',
            ));
            echo CHtml::button('CANCEL', array(
                'class' => 'ui-state-default ui-corner-all ui-button btn-cancel'
            ));
        ?></li>
        <!-- //buttons -->
    </ul>
</fieldset>

<?php $this->endWidget(); ?>